# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=sqlite3

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_amalgamationver=3080500
pkgver=3.8.5.0
pkgrel=1
pkgdesc="A C library that implements an SQL database engine (mingw-w64)"
arch=('any')
license=("custom:Public Domain")
groups=("${MINGW_PACKAGE_PREFIX}")
url="http://www.sqlite.org"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-ncurses" "${MINGW_PACKAGE_PREFIX}-readline")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-tcl")
source=("http://www.sqlite.org/2014/sqlite-autoconf-$_amalgamationver.tar.gz")
sha1sums=('7f667e10ccebc26ab2086b8a30cb0a600ca0acae')
options=('!strip' 'staticlibs')

build() {
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
  CFLAGS+=" -fexceptions -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_DISABLE_DIRSYNC=1 -DSQLITE_ENABLE_FTS3=3 -DSQLITE_ENABLE_RTREE=1 -fno-strict-aliasing"
  ../sqlite-autoconf-${_amalgamationver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-threadsafe
  make
}

package() {
  cd ${srcdir}/build-${CARCH}
  make DESTDIR="${pkgdir}" install
}
